<?php

namespace app\backend\validate;

use think\Validate;
use think\captcha\facade\Captcha;

class AdminValidate extends Validate {

	protected $rule = [
		'name' => 'require|max:25',
		'password' => 'require|between:6,12',
		// 'captcha' => 'require|checkCaptcha'
	];

	protected $message = [
		'name.require' => '用户名不能为空',
		'name.max' => '用户名不能超过25个字符',
		'password.require' => '密码不能为空',
		'password.between' => '密码必须在6-12位之间',
		'captcha.require' => '验证码不能为空',
		'captcha.checkCaptcha' => '验证码错误'
	];

	protected function checkCaptcha($value, $rule, $data=[]) {
		return Captcha::check($value) ? true : "验证码错误";
	}
}